<div class="form wide">

    <?php $form = $this->beginWidget('FActiveForm', array(
    'id' => 'language-form',
    'enableAjaxValidation' => false,
)); ?>

    <p class="note">Fields with <span class="required">*</span> are required.</p>

    <?php echo $form->errorSummary($model); ?>

    <?php if (!$model->IsNewRecord) echo $form->hiddenField($model, "id"); ?>
    <div class="row">

        <?php echo $form->labelEx($model, 'site_id'); ?>
        <?php echo $form->dropDownList($model, 'site_id', Site::siteList(), array('prompt' => '-Select site-')); ?>
        <?php echo $form->error($model, 'site_id'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'locale_id'); ?>
        <?php echo $form->dropDownlist($model, 'locale_id', $languageList, array('prompt' => 'Select one')); ?>
        <?php echo $form->error($model, 'locale_id'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'status', array('label' => 'Active'));$model->status = true; ?>
        <?php echo $form->checkBox($model, 'status', array('value' => true, 'unchecked' => false)); ?>
        <?php echo $form->error($model, 'status'); ?>
    </div>

    <div class="row buttons">
        <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
    </div>

    <?php $this->endWidget(); ?>

</div><!-- form -->
<script type="text/javascript">
    $(function () {
        $('select#Language_site_id').change(function () {
            var siteId = $('select#Language_site_id option:selected').val();
            if (siteId != '') {
                $.ajax({
                    url:'<?php echo $this->createUrl('refreshLanguageList');?>',
                    data:{'siteId':siteId},
                    success:function (html) {
                        $('select#Language_locale_id').html(html);
                    }
                });
            }
        });
    });
</script>